<?php
/**
 * 
 * Form Create User
 * @package Form
 * @filesource /application/forms
 * @author Windy
 *
 */
class Form_CreateUser extends Zend_Form
{
	private $formDecorators;
	private $elementDecorators;
	private $buttonDecorators;
	private $hiddenDecorators;
	
	/**
	 * 
	 * Constructor set id and class for form
	 * @param string $id
	 * @param string $class
	 */
	
    
    public function __construct($id= "", $class = "")
    {
    	$this->formDecorators = array(
    								array('FormElements'),
    								array('Form',array("name"=>$id, "class"=>$class))
    							);
    						
    	$this->elementDecorators = array(
    									array('Label', array()), 
    									array("HTMLTag",array("tag"=>"div","class"=>"row")),
    									array("Description",array("tag"=>"span"))
    								);
    	$this->buttonDecorators = array(
										array('ViewHelper'),
										array("HTMLTag",array("tag"=>"div","class"=>"buttons"))
										
									);
									
		$this->hiddenDecorators = array(
    									
    									array("HTMLTag",array("tag"=>"div")),
    									array("Description",array("tag"=>"span"))
    								);					
    	//add decorator for form
        $this->addDecorators($this->formDecorators);
        $this->setName('frmAEUser');
        
        //add textbox name=username
        $txtUsername = $this->createElement("text", "username")
        				->setLabel("Username:")
        				->setRequired(TRUE)
        				->setAttrib("size", 30)
        				->setValidators(array(new Zend_Validate_StringLength(array(8,15))))
        				->setFilters(array(new Zend_Filter_StringToLower()))
        				->setOptions(array('autocomplete'=> 'off'))
        				->addDecorators($this->elementDecorators);
        $this->addElement($txtUsername);
        
        //add textbox name= password;
        $txtPassword = $this->createElement("password", "password")
        				->setLabel("Mật khẩu đăng nhập:")
        				->setAttrib("size", 30)
        				->setOptions(array('autocomplete'=> 'off'))
        				->setValidators(array(
        									new Zend_Validate_StringLength(array(8,15))),
        									new Zend_Validate_Alnum()
        								)
        				->setFilters(array(new Zend_Filter_StringToLower()))
        				->addDecorators($this->elementDecorators);
        $this->addElement($txtPassword);
        
        //add textbox name = repassword
        $txtRePassword = $this->createElement("password", "repassword")
        				->setLabel("Xác nhận mật khẩu:")
        				->setAttrib("size", 30)
        				->setValidators(array(
        									new Zend_Validate_StringLength(array(8,15))),
        									new Zend_Validate_Alnum()
        								)
        				->setFilters(array(new Zend_Filter_StringToLower()))
        				->addDecorators($this->elementDecorators);
        $this->addElement($txtRePassword);
        
        //add textbox name = fullname
        $txtMobile = $this->createElement("text", "fullname")
       					 ->setLabel("Tên đầy đủ:")
       					 ->addFilters(
       						 array(new Zend_Filter_StringTrim()))
        				 ->setAttrib("size", 40)
       					 ->addDecorators($this->elementDecorators);
        $this->addElement($txtMobile);
        //add textbox name=email
        $txtEmail = $this->createElement("text", "email")
       					 ->setLabel("Email:")
       					 ->addFilters(
       						 array(new Zend_Filter_StringTrim(), new Zend_Filter_StringToLower()))
        				 ->setAttrib("size", 40)
       					 ->addDecorators($this->elementDecorators);
        $this->addElement($txtEmail);
        
        //add textbox name = mobile
        $txtMobile = $this->createElement("text", "phone")
       					 ->setLabel("Phone:")
       					 ->addValidator(new Zend_Validate_Digits())
       					 ->addFilters(
       						 array(new Zend_Filter_StringTrim(), new Zend_Filter_StringToLower()))
        				 ->setAttrib("size", 40)
       					 ->addDecorators($this->elementDecorators);
       	$this->addElement($txtMobile);
      	//add textbox name = mobile
        $txtFax = $this->createElement("text", "fax")
       					 ->setLabel("Fax:")
       					 ->addValidator(new Zend_Validate_Digits())
       					 ->addFilters(
       						 array(new Zend_Filter_StringTrim(), new Zend_Filter_StringToLower()))
        				 ->setAttrib("size", 40)
       					 ->addDecorators($this->elementDecorators);
        $this->addElement($txtFax);
        
        //add dropdown list name='role'
        $slcRole = $this->createElement("select", "role");
        $slcRole->setLabel("Vai trò:");
        $slcRole->setRequired(true);
        $slcRole->addMultiOptions(array(0 => "Administrator", 1 => "Nhân viên bán hàng"));
        $slcRole->addDecorators($this->elementDecorators);
        $this->addElement($slcRole);
        
        //add submit
        $this->addElement("submit", "submit", array('label' => "Lưu"));
        $this->addElement("reset", "reset", array('label' => "Làm lại"));
    }
	
}
?>